package org.example.shop_front_api.controller;

import org.example.shop_front_api.entity.Area;
import org.example.shop_front_api.service.AreaService;
import org.example.shop_front_api.utils.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/area")
public class AreaController {
    @Autowired
    private AreaService areaService;

    @GetMapping("/{parentId}")
    public JsonResult listByParentId(@PathVariable Long parentId) {
        List<Area> areaList = areaService.listByParentId(parentId);
        return JsonResult.success("查询区域列表成功", areaList);
    }
}